/**
 * @fileOverview 矩形
 * @author goodzsq@gmail.com
 */

var BaseShape = gg.module('shape.Base');

var Rect = BaseShape.extend({
    area: function() {
        return this.get('width') * this.get('height');
    },
    hasPoint: function(p) {
        var c = this.get('center');
        var w = this.get('width') / 2;
        var h = this.get('height') / 2;
        return p.x >= c.x - w && p.x <= c.x + w
                && p.y >= c.y - w && p.y <= c.y + w;
    }
});

Rect.metadata = _.extend({}, BaseShape.metadata, {
    width: {
        label: '宽',
        type: 'datatype.Number',
        defaultValue: 1
    },
    height: {
        label: '高',
        type: 'datatype.Number',
        defaultValue: 1
    }
});

module.exports = Rect;